/**
 * 
 */

App = Ember.Application.create();

App.Router.map(function() {
	this.resource('login');
	this.resource('about');
	this.resource('news');
	this.resource('tech-info');
});


App.Route = Ember.Route.extend({
	model: function(){
		//TODO look at cookies for values.
		return {
			email: '',
			password: ''
		};
	}
});



function loginEvent(e){
	if(e.keyCode == 13){
		var email = this._context.templateData.view.email.value;
		var password = this._context.templateData.view.password.value;
		
		var form = document.login;
		console.log(form);
		form.submit();
	}
}

App.LoginEmail = Ember.TextField.extend({
	formBlurred: null, // passed to the view helper as formBlurred=controllerPropertyName
	change: function(evt) {
		this.set('formBlurred', true);
	},
	keyPress: loginEvent
});

App.LoginPassword = Ember.TextField.extend({
	formBlurred: null, // passed to the view helper as formBlurred=controllerPropertyName
	change: function(evt) {
		this.set('formBlurred', true);
	},
	keyPress: loginEvent,
	type: 'password'
});






